package com.dehui.traders.ui.viewmodle;

import android.content.Context;
import android.databinding.ObservableField;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.util.Log;

import com.dehui.traders.R;
import com.dehui.traders.bean.ConstantTest;
import com.dehui.traders.kchart.DataParse;
import com.dehui.traders.kchart.KLineBean;
import com.dehui.traders.kchart.KLineManager;
import com.dehui.traders.kchart.MyBottomMarkerView;
import com.dehui.traders.kchart.MyCombinedChart;
import com.dehui.traders.kchart.MyHMarkerView;
import com.dehui.traders.kchart.MyLeftMarkerView;
import com.dehui.traders.ui.activity.StocksDetailActivity;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.CandleData;
import com.github.mikephil.charting.data.CandleDataSet;
import com.github.mikephil.charting.data.CombinedData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import com.github.mikephil.charting.utils.ViewPortHandler;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

import me.goldze.mvvmhabit.base.BaseViewModel;

/**
 * Created by hqq on 18.4.2.
 */

public class StocksDetailViewModel extends BaseViewModel{

    public ObservableField<String> stocksDetailName = new ObservableField<>();
    private DataParse mData;

    public StocksDetailViewModel(Context context, String name) {
        super(context);
        stocksDetailName.set(name);
    }

    public void initKLine(MyCombinedChart mChartKline) {
        getOffLineData();
        KLineManager.getInstange().initKLine(context,mChartKline,mData);
    }


    private void getOffLineData() {
        /*方便测试，加入假数据*/
        mData = new DataParse();
        JSONObject object = null;
        try {
            object = new JSONObject(ConstantTest.KLINEURL);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.d("数据-----", object.toString());
        mData.parseKLine(object);
    }

}
